package io.renren.modules.udp.controller;

import java.util.Arrays;
import java.util.Map;

import io.renren.modules.udp.entity.R5rmDeviceEntity;
import io.renren.modules.udp.service.R5rmDeviceService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 装置效率
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2020-01-13 11:58:57
 */
@RestController
@RequestMapping("udp/r5rmdevice")
public class R5rmDeviceController {
    @Autowired
    private R5rmDeviceService r5rmDeviceService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("udp:r5rmdevice:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = r5rmDeviceService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{devId}")
    @RequiresPermissions("udp:r5rmdevice:info")
    public R info(@PathVariable("devId") Long devId){
		R5rmDeviceEntity r5rmDevice = r5rmDeviceService.selectById(devId);

        return R.ok().put("r5rmDevice", r5rmDevice);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("udp:r5rmdevice:save")
    public R save(@RequestBody R5rmDeviceEntity r5rmDevice){
		r5rmDeviceService.insert(r5rmDevice);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("udp:r5rmdevice:update")
    public R update(@RequestBody R5rmDeviceEntity r5rmDevice){
		r5rmDeviceService.updateById(r5rmDevice);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("udp:r5rmdevice:delete")
    public R delete(@RequestBody Long[] devIds){
		r5rmDeviceService.deleteBatchIds(Arrays.asList(devIds));

        return R.ok();
    }

}
